import { http } from "@/utils/http";
// 获取自定义的参数
const getPcToken = () => {
  return localStorage.getItem("pcToken");
};
const baseProxy = import.meta.env.VITE_BASEPROXY;
/** 获取物品管理列表 */
export const getGoodsById = (id?: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgGoods/queryGoodsList`,
    {
      data: {
        scriptId: id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 删除物品 */
export const delGoods = (id?: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgGoods/deleteGoods`,
    {
      data: {
        id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 新增物品 */
export const addGoods = (item?: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgGoods/createGoods`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 更新物品 */
export const updateGoods = (item?: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgGoods/updateGoods`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
